const {app,BrowserWindow} = require('electron')
const path  = require('path')


let mainwindow = null
function mainWndow(){
    let window = new BrowserWindow({
        width:1000,
        height:800,
        webPreferences:{
            //开启node支持
            nodeIntegration: true,
            contextIsolation: false,
            //开启webview支持
            webviewTag:true,
            preload:path.resolve(__dirname,'../preload/preload.js') //预加载脚本
        }
    })
    window.loadURL(app.isPackaged //判断是否打包
        ?path.resolve(__dirname,'../render/index.html')
        :'http://localhost:1314/#/')
    window.webContents.openDevTools()
    return window
}

app.on('ready',()=>{
    mainwindow = mainWndow()
    console.log(mainwindow)
})

